/*
 * @Author: meixianming
 * @Date: 2022-11-14 16:34:23
 * @LastEditors: WeijianXu weijian.xu@unidt.com
 * @LastEditTime: 2024-05-11 15:21:51
 * @Description: file content
 * @FilePath: /front-end-of-task-center/src/api/infra/file.js
 */
import request from "@/utils/request";
import { uploadFilePath, getFileUrl } from '@/config/env'

// 删除文件
export function deleteFile(id) {
  return request({
    url: "/infra/file/delete?id=" + id,
    method: "delete",
  });
}

// 获得文件分页
export function getFilePage(query) {
  return request({
    url: "/infra/file/page",
    method: "get",
    params: query,
  });
}

// 文件上传
export function postFileUpload(data) {
  return request({
    url: uploadFilePath,
    method: "post",
    data: data,
  }).then((res) => {
    return {
      ...res,
      data: getFileUrl(res.data), // 修正文件名，使用相对路径
    }
  });
}
